package cn.com.infohold.smartcity.api;

import java.io.File;
import java.util.List;

import cn.com.infohold.smartcity.BuildConfig;
import cn.com.infohold.smartcity.api.bean.ApproveBean;
import cn.com.infohold.smartcity.api.bean.ChengBaoFangBean;
import cn.com.infohold.smartcity.api.bean.DisputeBean;
import cn.com.infohold.smartcity.api.bean.FaBaoFangBean;
import cn.com.infohold.smartcity.api.bean.LandInfoBean;
import cn.com.infohold.smartcity.api.bean.LandResult;
import cn.com.infohold.smartcity.api.bean.MessageList;
import cn.com.infohold.smartcity.api.bean.ModifyPasswordResult;
import cn.com.infohold.smartcity.api.bean.NewsBean;
import cn.com.infohold.smartcity.api.bean.RelativeBean;
import cn.com.infohold.smartcity.api.bean.Session;
import cn.com.infohold.smartcity.api.bean.UpdateInfo;
import cn.com.infohold.smartcity.api.bean.UploadAvatarResult;
import cn.com.infohold.smartcity.api.bean.UserInfo;
import cn.com.infohold.smartcity.api.bean.WarrantBean;
import cn.com.infohold.smartcity.bean.RelativeListBean;
import library.http.Download;
import library.http.FilePart;
import library.http.annotations.BaseUrl;
import library.http.annotations.Cache;
import library.http.annotations.Debuggable;
import library.http.annotations.Field;
import library.http.annotations.FormUrlEncoded;
import library.http.annotations.GET;
import library.http.annotations.Multipart;
import library.http.annotations.POST;
import library.http.annotations.Params;
import library.http.annotations.Part;
import library.http.annotations.Path;
import library.http.annotations.Proxy;
import library.http.annotations.Query;
import library.http.annotations.Timeout;
import library.http.serializable.SerializeParams;


/**
 * Created by Mr.Fan on 2017/3/25.
 */

@BaseUrl(BuildConfig.API_BASE_URL)
//@SslKey(path = "ssl/client.p12", pwd = "123456", keyType = "PKCS12")
//@SslTrust(path = "ssl/client.bks", pwd = "123456", keyType = "bks")
@Proxy(host = library.BuildConfig.BUILD_IP, port = 8888)
@Timeout(connect = 8000, write = 8000, read = 8000)
public interface API {
    String DCMS_MOBILE = "dcms";
    String MOUDLE = DCMS_MOBILE;

    @GET(MOUDLE + "/PwasAdmin/AppAdmin-downWeex.action?apkType=" + BuildConfig.FLAVOR)
    HttpHook<File> downloadWeex(Download<File> download);

    @GET(MOUDLE + "/PwasAdmin/AppAdmin-downApk.action?apkType=" + BuildConfig.FLAVOR)
    HttpHook<File> downloadApk(Download<File> download);

    @POST(BuildConfig.API_BASE_URL + "/landflow/authority/login.action")
    @FormUrlEncoded
    HttpHook<String> login(@Field("loginName") String username,
                           @Field("password") String password);

    @POST(MOUDLE + "/PwasAdmin/mobile-editMobilePwd.action")
    @FormUrlEncoded
    HttpHook<ModifyPasswordResult> modifyPassword(@Field("id") String id,
                                                  @Field("logonpassword") String _old,
                                                  @Field("pwd") String _new,
                                                  @Field("conPassword") String _confirm);

    @POST(MOUDLE + "/PwasAdmin/mobile-updMbUserPic.action?id={id}")
    @Multipart
    @Debuggable()
    HttpHook<UploadAvatarResult> uploadAvatar(@Path("id") String id,
                                              @Part("file") FilePart filePart);

    @GET(MOUDLE + "/{url}")
    HttpHook getAvatar(@Path("url") String url);


    @GET(MOUDLE + "/PwasAdmin/AppAdmin-getDownApkOrWeex.action")
    @Params(key = {"platform", "buildType", "flavor", "nativeVersionName", "nativeVersion"},
            value = {"android", BuildConfig.BUILD_TYPE, BuildConfig.FLAVOR, BuildConfig.VERSION_NAME, "" + BuildConfig.VERSION_CODE})
    HttpHook<UpdateInfo> checkUpdate(@Query("hybridVersion") String hybridVersion);

    @Cache("max-age=60")
    @GET(MOUDLE + "/PwasAdmin/MobileMessage-getMsg.action")
    HttpHook<MessageList> getMessageList(@Query("userId") String userId,
                                         @Query("pagenum") int pagenum,
                                         @Query("pagesize") int pagesize,
                                         @Query("isread") int isread);

    @POST(MOUDLE + "/pwasCase/Case-viewMsg.action")
    @FormUrlEncoded
    HttpHook<String> setMessageRead(@Field("msgId") String msgId);


    @POST(BuildConfig.API_BASE_URL + "/landflow/landinfo/getLands.do")
    @FormUrlEncoded
    HttpHook<String> getLands(@Field("curPage") int curPage,
                              @Field("pageSize") int pageSize,
                              @Field("userid") String userid,
                              @Field("bgcode") String bgcode,
                              @Field("roles") int roles,
                              @Field("approvalStatus") int approvalStatus,
                              @Field("code") String code,
                              @Field("name") String name,
                              @Field("propertycode") String propertycode);

    @GET(BuildConfig.API_BASE_URL + "/landflow/conpart/get.do")
    HttpHook<String> getFBList(@Query("curPage") int curPage,
                               @Query("pageSize") int pageSize,
                               @Query("name") String name,
                               @Query("bgcode") String bgcode,
                               @Query("wheelman") String wheelman);

    @GET(BuildConfig.API_BASE_URL + "/landflow/contractor/get.do")
    HttpHook<String> getCBList(@Query("pageSize") int pageSize,
                               @Query("curPage") int curPage,
                               @Query("bgcode") String bgcode,
                               @Query("keyword") String keyword,
                               @Query("name") String name,
                               @Query("tel") String tel);

    @GET(BuildConfig.API_BASE_URL + "/landflow/warrant/getList.do")
    HttpHook<String> getWarrantList(@Query("curPage") int curPage,
                                    @Query("pageSize") int pageSize,
                                    @Query("userid") String userid,
                                    @Query("bgcode") String bgcode,
                                    @Query("roles") int roles,
                                    @Query("approvalStatus") Integer approvalStatus,
                                    @Query("contractnumber") String contractnumber,
                                    @Query("code") String code,
                                    @Query("certificatecode") String certificatecode);

    @GET(BuildConfig.API_BASE_URL + "/landflow/policy/getListByPages.do")
    HttpHook<String> getNewstList(@Query("curPage") int curPage,
                                  @Query("pageSize") int pageSize,
                                  @Query("status") int status,
                                  @Query("bgcode") String bgcode,
                                  @Query("title") String title,
                                  @Query("publisher") String publisher,
                                  @Query("policytype") int policytype);

    @GET(BuildConfig.API_BASE_URL + "/landflow/dispute/getListByPages.do")
    HttpHook<String> getDisputetList(@Query("curPage") int curPage,
                                     @Query("pageSize") int pageSize,
                                     @Query("disputeStatus") int disputeStatus,
                                     @Query("bgcode") String bgcode);

    @POST(BuildConfig.API_BASE_URL + "/landflow/landinfo/saveOrUpdate.do")
    @FormUrlEncoded
    HttpHook<String> updateLandinfo(@SerializeParams LandInfoBean landInfoBean);

    @POST(BuildConfig.API_BASE_URL + "/landflow/conpart/save.do")
    @FormUrlEncoded
    HttpHook<String> addFabaofang(@SerializeParams FaBaoFangBean faBaoFangBean);

    @POST(BuildConfig.API_BASE_URL + "/landflow/contractor/save.do")
    @FormUrlEncoded
    HttpHook<String> addChengbaofang(@SerializeParams ChengBaoFangBean chengBaoFangBean);

    @POST(BuildConfig.API_BASE_URL + "/landflow/warrant/save.do")
    @FormUrlEncoded
    HttpHook<String> addWarrant(@SerializeParams WarrantBean warrantBean);

    @GET(BuildConfig.API_BASE_URL + "/landflow/warrant/getDetailById.do")
    HttpHook<String> getWarrantDetail(@Query("id") String id);

    @POST(BuildConfig.API_BASE_URL + "/landflow/contractor/saveOrUpdateRelative.action")
    @FormUrlEncoded
    HttpHook<String> addRelative(@SerializeParams RelativeListBean relativeList);

    @GET(BuildConfig.API_BASE_URL + "/landflow/dispute/checkIsExist.do")
    HttpHook<String> checkDisputeExist(@Query("type") String type,
                                       @Query("objId") String objId);

    @POST(BuildConfig.API_BASE_URL + "/landflow/dispute/saveOrUpdate.do")
    @FormUrlEncoded
    HttpHook<String> addDispute(@SerializeParams DisputeBean disputeBean);

    @POST(BuildConfig.API_BASE_URL + "/landflow/policy/saveOrUpdate.do")
    @FormUrlEncoded
    HttpHook<String> addPublishInfo(@SerializeParams NewsBean newsBean);

    @POST(BuildConfig.API_BASE_URL + "/landflow/approve/approve.do")
    @FormUrlEncoded
    HttpHook<String> approveData(@SerializeParams ApproveBean approveBean);

    @GET(BuildConfig.API_BASE_URL + "/landflow/contractor/getRelativesListByContractorId.action")
    HttpHook<String> getRelativesList(@Query("contractorid") String contractorid);

    @GET(BuildConfig.API_BASE_URL + "/landflow/landinfo/getByUserId.do")
    HttpHook<String> getLandById(@Query("userid") String userid);


}
